function init_page_datatable(obj, loadSuccess) {
	
	var currentPage_=1;
	
    function serializeObject(obj, aoData) {
        var a = obj.serializeArray();
        $.each(a,
        function() {
            aoData[this.name] = this.value || ""
        });
        return aoData
    }
    var datatableInit = function(me) {
        var dataTableId = $(me).attr("id");
        var pageSize = $(me).data("page-size") || 10;
        var checkcallback;
        var aoColumns = [];
        var oTable;
        function retrieveData(page,pageSize_) {
            var sSource = $("#" + dataTableId).data("action");
            var aoData = {};
            var params = $("#" + dataTableId).data("params");
            if ($.isNotEmpty(params)) {
                for (var name in params) {
                    aoData[name] = params[name]
                }
            }
            aoData = serializeObject($("#" + dataTableId + "_form"), aoData);
            aoData["pageSize"] = pageSize_||$("#" + dataTableId).data("page-size");
            
            aoData["pageIndex"] = currentPage_;
            $.ajax({
                "dataType": "json",
                "type": "POST",
                "url": sSource,
                "data": aoData,
                "beforeSend": function() {
                    jQuery(".loading").removeClass("ui-hidden")
                },
                "complete": function(XMLHttpRequest, textStatus) {
                    jQuery(".loading").addClass("ui-hidden")
                },
                "success": function(json) {
                    if (json == null || json == "" || json == undefined || json.code > 0) {
                        if (json == undefined) {
                            jQuery.notify("错误提示", "操作错误!")
                        } else {
                            if (json.code == 10000) {
                            	jQuery.notify({
                                    title: "<span class='red-check'>错误提示</span>",
                                    content: "<span class='red-check'>您没有资源操作权限!</span>",
                                })
                            } else {
                                jQuery.notify("错误提示!", json.message || "");
                                if (json.data.data != undefined) {
                                    fnCallback(json.data, dataTableId)
                                }
                            }
                        }
                    } else {
                    	laypage({
                            cont: "page_text",
                            skip: true,
                            skin: 'molv',
                            pages: json.data.totalPages,
                            prev: '<',
                            next: '>',
                            first: 1,
                            pageNum:json.data.pageSize,
                            last: json.data.totalPages,
                            curr: json.data.page,
                            jump: function(obj,first) {
                            	 if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                            		 currentPage_=obj.curr;
                                     retrieveData(obj.curr,obj.everyPage)
     	                        }
                            }
                        });
                        if (json.data.data != undefined) {
                            fnCallback(json.data, dataTableId)
                        }
                    }
                },
                "error": function(xhr, textStatus, errorThrown) {
                    var error_msg = "<div>Http status: " + xhr.status + " " + xhr.statusText + ",textStatus: " + textStatus + ",errorThrown: " + errorThrown.name + "</div>";
                    //jQuery.notify("错误提示!", error_msg)
                    jQuery.notify("错误提示", "操作错误,请刷新页面!")
                }
            })
        }
        var fnCallback = function(page, tableId) {
        	var data=page.data;
            var html = [];
            for (var i = 0; i < data.length; i++) {
                var row = data[i];
                html.push("<tr>");
                for (var j = 0; j < aoColumns.length; j++) {
                    var col = aoColumns[j];
                    var cLable = col["mData"];
                    var cData = row[cLable];
                    if (typeof col["mRender"] === "function") {
                        var returnHtml = col["mRender"](cData, cLable, row);
                        html.push("<td>" + returnHtml + "</td>")
                    } else {
                        if (cData != undefined && cData != "undefined" && cData != null && cData != "") {
                            html.push("<td>" + cData + "</td>")
                        } else {
                            html.push("<td></td>")
                        }
                    }
                }
                html.push("</tr>")
            }
            if (page.totalCount > 0) {
            	$("#page_left_text").show();
                $("#page_left_text").html("当前显示第<strong>&nbsp;" + (((page.page - 1) * page.pageSize) + 1) + "&nbsp;</strong>到<strong>&nbsp;" + ((page.page) * page.pageSize > page.totalCount ? page.totalCount: (page.page) * page.pageSize) + "&nbsp;</strong>条,&nbsp;共计<strong>&nbsp;" + page.totalCount + "&nbsp;</strong>条<strong>&nbsp;" + page.totalPages + "&nbsp;</strong>页")
            }else{
            	$("#page_left_text").hide();
            }
            $("#" + tableId).data("page-size",page.pageSize);
            $("#" + tableId + " > tbody").html(html.join("")).trigger("footable_redraw");
            if(loadSuccess){
                loadSuccess()
            }
            if (typeof window[checkcallback] === 'function'){
            	$("#" + tableId + " input:checkbox[class=mycheckbox]").on("click",function() {
            		var checkAllIds=[];
                	$("#" + dataTableId + " input:checkbox[class=mycheckbox]:checked").each(function() {
            	        checkAllIds.push($(this).data("id"));
                	});
                	var checkId=$(this).data("id");
                	window[checkcallback](checkAllIds.join(","),checkId);
                });
            }
        };
        $("#" + dataTableId).find("thead > tr:eq(0) > th,thead > tr:eq(0) > td").each(function(index, element) {
            var $this = $(this);
            var item_o = {};
            item_o["mData"] = $this.data("title") || "";
            if ($this.data("crud")) {
                item_o["mRender"] = function(data, name, row) {
                    var th_div_html = $.trim($this.find("div:hidden").html() || "");
                    if (th_div_html == "") {
                        return ""
                    }
                    var html=[];
                    $this.find("button").each(function(index) {
                        if ($(this).data("type") == "change") {
                        	var th_callback = $(this).data("callback");
                            var th_toge = $(this).data("toge");
                            if (th_toge == undefined || th_toge == "") {
                            	if (th_callback != undefined && th_callback != "") {
                            		html.push(eval(th_callback)(data, name, row));
                                } 
                            }else{
                            	if (th_callback != undefined && th_callback != "") {
                                	var list={};
                                	$.each(th_toge.split(","), function() {
                                		list[this]=row[this];
                                	}); 
                                	html.push(eval(th_callback)(data, name, row,list));
                                } 
                            }
                        }else{
                        	html.push($(this).prop('outerHTML'));
                        }
                    });
                    th_div_html=html.join("");
                    var title = $this.data("title");
                    for (var key in title) {
                        do {
                            th_div_html = th_div_html.replace(":" + key, row[title[key]])
                        } while ( th_div_html . indexOf ( key ) != -1)
                    }
                    return th_div_html
                }
            } else {
                var type = $this.data("type");
                if (type == "enum") {
                    item_o["mRender"] = function(data, name, row) {
                        var opts = $this.data("opt");
                        for (var key in opts) {
                            if (data == key) {
                                return opts[key]
                            }
                        }
                        return ""
                    }
                } else if (type == "checkbox") {   
                	checkcallback=$this.data("callback");	
                	
                    var callback2 = $this.data("callback2");
                    if (callback2 != undefined && callback2 != "") {
                    	item_o["mRender"] = function(data, name, row) {
                    		return eval(callback2)(data, name, row)
                        }
                    }else{
                    	item_o["mRender"] = function(data, name, row) {
                    		var th_div_html ='<input class="mycheckbox" type="checkbox" id=":id" data-id=":id" >';
                            var key = ":id";
                            do {
                                th_div_html = th_div_html.replace(key,data)
                            } while ( th_div_html.indexOf(key) != -1)
                            return th_div_html
                        }
                    }
                } else if (type == "callback") {
                    var th_callback = $this.data("callback");
                    if (th_callback != undefined && th_callback != "") {
                        item_o["mRender"] = eval(th_callback)
                    }
                } else if (type == "togecallback") {
                    var th_callback = $this.data("callback");
                    var th_toge = $this.data("toge");
                    var title = $this.data("title");
                    if (th_toge == undefined || th_toge == "") {
                    	if (th_callback != undefined && th_callback != "") {
                    		item_o["mRender"] = eval(th_callback)
                        } 
                    }else{
                    	if (th_callback != undefined && th_callback != "") {
                    		var th_toges=th_toge.split(",");
                            item_o["mRender"] = function(data, name, row) {
                            	var list={};
                            	$.each(th_toges, function() {
                            		list[this]=row[this];
                            	}); 
    		                    return eval(th_callback)(data, name, row,list);
                            }
                        } 
                    }
                } else  if (type == "datetime") {
                    var formater = $this.data("formater");
                    if (formater == undefined || formater == "") {
                        formater = "yyyy-MM-dd HH:mm:ss"
                    }
                    item_o["mRender"] = function(data, name, row) {
                        if (data == undefined || data == "") {
                            return ""
                        }
                        return new Date(data).format(formater)
                    }
                } else if (type == "date") {
                    var formater = $this.data("formater");
                    if (formater == undefined || formater == "") {
                        formater = "yyyy-MM-dd"
                    }
                    item_o["mRender"] = function(data, name, row) {
                        if (data == undefined || data == "") {
                            return ""
                        }
                        return new Date(data).format(formater)
                    }
                } else  if (type == "substr") {
                    var range = $this.data("range");
                    if (range == undefined || range == "") {
                        range = "1,2"
                    }
                    var start = Number(range.substr(0, 1));
                    var end = Number(range.substr(2, 3));
                    if (start == undefined || start == "") {
                        start = 0
                    }
                    if (end == undefined || end == "") {
                        end = 100
                    }
                    item_o["mRender"] = function(data, name, row) {
                        if (data == undefined || data == "") {
                            return ""
                        }
                        if (data.length < end) {
                            return data
                        }
                        return data.substr(start, end) + "..."
                    }
                }
            }
            aoColumns.push(item_o)
        });
        $("#" + dataTableId).data("page-size", pageSize);
        $("#" + dataTableId).footable();
        $("#" + dataTableId + "_search").on("click",function() {
            retrieveData(1)
        });
        retrieveData()
    };
    if (obj == null || obj == "") {
        $("table[data-datatable=true]").each(function() {
        	datatableInit($(this))
        })
    } else {
        datatableInit(obj)
    }
};